package com.auth.sdk.auth;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;

/**
 * Auth aspect
 *
 * @description: 拦截控制器方法
 * @author: cyj
 * @date 2021 -12-15 14:07:13
 *
 *
 */
@Aspect
@Slf4j
@Order(Integer.MIN_VALUE)
public class AuthAspect {
    /**
     * Auth point
     */
    @Pointcut("@within(org.springframework.web.bind.annotation.RestController)")
    public void authPoint() {
    }

    /**
     * Auth around object
     *
     * @param pjp pjp
     * @return the object
     * @throws Throwable throwable
     */
    @Around("authPoint()")
    public Object authAround(ProceedingJoinPoint pjp) throws Throwable {
        log.info("开始权限校验！");
        AuthManage.auth.auth(pjp);
        log.info("权限校验通过！！");
        return pjp.proceed();
    }
}
